﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Editor.Custom_Controls;

namespace Editor.QuestionInterface
{
    public partial class ChoiceBasedHelperQuestion : HelperQuestionUserControl, ChoiceQuestion
    {
        private string correctAnswer;

        public ChoiceBasedHelperQuestion()
        {
            InitializeComponent();
        }

        private void ChoiceBasedHelperQuestion_Load(object sender, EventArgs e)
        {
            transparentLabelQuestion.Text = BodyText;
            string[] answers = Answer.Split(new string[] { "; " }, StringSplitOptions.RemoveEmptyEntries);
            UtilityButton[] buttons = new UtilityButton[] { utilityButtonAnswer1, utilityButtonAnswer2, utilityButtonAnswer3,
                utilityButtonAnswer4 };

            for (int i = 0; i < answers.Length - 1; ++i)
            {
                buttons[i].Visible = true;
                buttons[i].Text = answers[i];
            }
            correctAnswer = answers[answers.Length - 1];
        }

        private void utilityButtonAnswer1_Click(object sender, EventArgs e)
        {
            if (utilityButtonAnswer1.Text == correctAnswer)
            {
                QuestionParent.Result = "DOĞRU CEVAP. TEBRİKLER!";
                QuestionParent.Description = CorrectAnswerDescription;
            }
            else
            {
                QuestionParent.Result = "YANLIŞ CEVAP. TEKRAR DENEYİN.";
                QuestionParent.Description = IncorrectAnswerDescription;
            }
        }

        private void utilityButtonAnswer2_Click(object sender, EventArgs e)
        {
            if (utilityButtonAnswer2.Text == correctAnswer)
            {
                QuestionParent.Result = "DOĞRU CEVAP. TEBRİKLER!";
                QuestionParent.Description = CorrectAnswerDescription;
            }
            else
            {
                QuestionParent.Result = "YANLIŞ CEVAP. TEKRAR DENEYİN.";
                QuestionParent.Description = IncorrectAnswerDescription;
            }
        }

        private void utilityButtonAnswer3_Click(object sender, EventArgs e)
        {
            if (utilityButtonAnswer3.Text == correctAnswer)
            {
                QuestionParent.Result = "DOĞRU CEVAP. TEBRİKLER!";
                QuestionParent.Description = CorrectAnswerDescription;
            }
            else
            {
                QuestionParent.Result = "YANLIŞ CEVAP. TEKRAR DENEYİN.";
                QuestionParent.Description = IncorrectAnswerDescription;
            }
        }

        private void utilityButtonAnswer4_Click(object sender, EventArgs e)
        {
            if (utilityButtonAnswer4.Text == correctAnswer)
            {
                QuestionParent.Result = "DOĞRU CEVAP. TEBRİKLER!";
                QuestionParent.Description = CorrectAnswerDescription;
            }
            else
            {
                QuestionParent.Result = "YANLIŞ CEVAP. TEKRAR DENEYİN.";
                QuestionParent.Description = IncorrectAnswerDescription;
            }
        }
    }
}
